﻿<UserControls:ScrumItemControlBase x:Class="ScrumTable.UI.View.WinTouch.UserControls.UserStoryControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:s="http://schemas.microsoft.com/surface/2008" xmlns:Converter="clr-namespace:ScrumTable.UI.View.Converter;assembly=ScrumTable.UI.View"
    xmlns:Util1="clr-namespace:ScrumTable.UI.View.Util;assembly=ScrumTable.UI.View" xmlns:CustomControl="clr-namespace:ScrumTable.UI.View.CustomControl;assembly=ScrumTable.UI.View" xmlns:UserControls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls" xmlns:PieChart="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.PieChart" xmlns:Localization="clr-namespace:ScrumTable.UI.View.Localization;assembly=ScrumTable.UI.View" xmlns:CustomControl1="clr-namespace:ScrumTable.UI.View.WinTouch.CustomControl" xmlns:Controls="clr-namespace:ScrumTable.UI.View.WinTouch.UserControls.HtmlRichText.Controls" x:Name="UserStoryRoot"
    TouchDown="OnUserStoryPreviewContactDown" MouseDown="OnPreviewMouseDown" s:SurfaceDragDrop.Drop="OnUserStoryDrop" s:SurfaceDragDrop.PreviewQueryTarget="OnUserStoryPreviewQueryTarget"  AllowDrop="True">
    <UserControls:ScrumUserControl.Resources>
        <Converter:ConverterEnumEqual x:Key="ConverterEnum"/>
        <Converter:ConverterIsNullVisibility x:Key="ConverterIsNullVisibility"/>        
        <Converter:ConverterBoolVisibility x:Key="ConverterIsVisible"/>
        <Converter:ConverterUserStoryEffect x:Key="ConverterUserStoryBackGround"/>
        <Storyboard x:Key="StoryPointsChangeAnimation">
            <DoubleAnimation Storyboard.TargetName="StoryPointsChangedEllipse" Storyboard.TargetProperty="Opacity" From="0" To="0.75" AutoReverse="True" FillBehavior="Stop"  Duration="0:0:1" />
        </Storyboard>
        </UserControls:ScrumUserControl.Resources>
        <Grid Effect="{Binding Path=Parent, Converter={StaticResource ConverterUserStoryBackGround}}"> 

            <!-- Star with Story Points at the right top  -->
        <Grid VerticalAlignment="Top" HorizontalAlignment="Right" Panel.ZIndex="1" Width="25" Height="25">
            <UserControls:StarControl Panel.ZIndex="1" VerticalAlignment="Top" StrokeBrush="Black" FillBrush="{x:Null}"/>
            <Util1:ViewModelChangeDispatcher Source="{Binding StoryPoints}" OnSourceChangedStartStoryboard="{StaticResource StoryPointsChangeAnimation}"/>                                                
            <PieChart:SimplePieChart Panel.ZIndex="0" Opacity="1" FirstColor="#7FFF7F" SecondColor="#FF7F7F" BackColor="LightBlue" FirstValue="{Binding Path=TotalWorkCompleted}" SecondValue="{Binding Path=TotalWorkRemaining}" Width="21" Height="21" VerticalAlignment="Center" HorizontalAlignment="Center" />                                    
            <Label x:Name="StoryPointsLabel" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Black" FontSize="10" FontWeight="Bold" Content="{Binding Path=StoryPoints}" />
            <Ellipse x:Name="StoryPointsChangedEllipse" Width="22" Height="22" Opacity="0" Fill="Black">
                <Ellipse.Effect>
                    <BlurEffect Radius="10"></BlurEffect>
                </Ellipse.Effect>
            </Ellipse>
        </Grid>
      
        <Grid Panel.ZIndex="1" Width="25" Height="22" Margin="0,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
            <CustomControl:StateIcon State="{Binding State}" Icon="IconUserStory"/>
        </Grid>
            
        
 
        


        <!-- Member Image left -->
        <Grid Panel.ZIndex="1" Visibility="{Binding Path=AssignedMember, Converter={StaticResource ConverterIsNullVisibility}}" VerticalAlignment="Bottom" HorizontalAlignment="Right">
            <Border BorderThickness="2" Background="White" BorderBrush="{Binding AssignedMember.Color}">
                <CustomControl:WebAsyncReportMemberImage  UriBitmap="{Binding AssignedMember.Picture}" MaxHeight="25" MaxWidth="25"></CustomControl:WebAsyncReportMemberImage>
            </Border>
        </Grid>
        <Border BorderBrush="#FF000000" Background="{StaticResource UserStoryBackGroundColor}"  BorderThickness="2,2,2,2" CornerRadius="2,2,2,2" Margin="12,7,7,7" VerticalAlignment="Stretch" >
            <Grid x:Name="DropRoot" >
                <TextBlock   Padding="0"  VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,16,-3,0">
                    <TextBlock.Text>
                        <Binding StringFormat="# {0}" Path="BackEndId"/>
                    </TextBlock.Text>                    
                    <TextBlock.LayoutTransform>
                        <RotateTransform Angle="90"/>
                    </TextBlock.LayoutTransform>
                </TextBlock>
                <CustomControl1:ScrumTableScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" x:Name="ScrollDetail">
                    <StackPanel Orientation="Vertical" Margin="12,0,0,0">
                        <Label   x:Name="NameLabel" Padding="0,5,9,5" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=FontSize}">
                            <TextBlock TextBlock.FontWeight="Bold"  TextWrapping="WrapWithOverflow" Text="{Binding Path=Name}" TextAlignment="Left">
                            </TextBlock>
                        </Label>

                        <Border BorderBrush="Black" BorderThickness="0,1,0,0" Margin="0,5,10,0" Padding="0" HorizontalAlignment="Stretch" Visibility="{Binding ElementName=UserStoryRoot, Path=IsPlaceForAddInfo, Converter={StaticResource ResourceKey=ConverterIsVisible}}">
                            <StackPanel  HorizontalAlignment="Stretch">
                                <!--
                                <Label Margin="0,0,0,0" Padding="0">
                                    <Localization:Translate Uid="UserStory_Description" Default="[Description]" />
                                </Label>
                                -->
                                <UserControl Margin="0,0,0,0" Padding="0"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                                    <Grid >
                                        <Rectangle Fill="White" Opacity="0.5">
                                        </Rectangle>
                                        <Controls:RichTextHtmlBox  Panel.ZIndex="10" Padding="2" Text="{Binding Description, Mode=OneWay}" IsHtml="{Binding IsDescriptionHtml}"  />
                                        <!--
                                        <TextBlock Padding="2" TextWrapping="WrapWithOverflow" Text="{Binding Path=Description}" TextAlignment="Left">
                                        </TextBlock>
                                        -->
                                    </Grid>
                                </UserControl>
                            </StackPanel>
                        </Border>
                    </StackPanel>
                </CustomControl1:ScrumTableScrollViewer>
               
                <Border VerticalAlignment="Bottom" HorizontalAlignment="Left"  Margin="-5,0,0,0">
                    <Label x:Name="Ranking" Content="{Binding Path=Ranking}">
                        <Label.LayoutTransform>
                            <RotateTransform Angle="-90"></RotateTransform>
                        </Label.LayoutTransform>
                    </Label>
                </Border>
            </Grid>
                
        </Border>
       
    </Grid>
</UserControls:ScrumItemControlBase>
